package src.com.doit.Demo08练习;

import java.util.ArrayList;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        double zongZichan = 100000;
        ArrayList<Employee>list=new ArrayList<>();
        list.add(new JingLi("段红光","001",1000000,10000,500000));
        list.add((new ChuShi("旺仔","002",500000,80000)));
        list.add(new FuWuYuan("复合肥","003",25000,2500));
        GongSi gs = new GongSi(zongZichan,list);
        System.out.println("----------未发工资前-------------");
        gs.show();
        System.out.println("-------------发工资后---------------");
        gs.show();
        System.out.println("--------------随机抽取一名幸运员工,为其调薪------------------");
        gs.lucky();
        System.out.println("--------------指定一位员工,为其调薪----------------------------");
        method(list);
    }
    public static void method(ArrayList<Employee>list) {
        as:while (true) {
            System.out.print("输入想要调薪员工的编号:");
            System.out.println("1-----段红光     2------旺仔    3------复合肥");
            Scanner sc = new Scanner(System.in);
            int i = sc.nextInt();
            if(i<1 || i>3)
                System.out.println("输入数字不正确,请重新输入");
            else {
                System.out.println("您要为" + list.get(i - 1).getName() + "调薪");
                System.out.print("请输入为其调薪的额度:");
                double e = sc.nextDouble();

                Employee j = list.get(i - 1);
                GongSi g = new GongSi();
                g.setGongZi(j, e);

                while(true)
                {
                    System.out.println("继续调薪请按1,退出请按2");
                    int a = sc.nextInt();
                    if(a==1)
                        method(list);
                    else if (a==2)
//                        System.exit(0);
                        break as ;
                    else if(a!=1 && a!=2)
                    {
                        System.out.println("输入数字不正确,请重新输入");
                    }
                }
            }
        }
    }
}
